package com.example.clientmiviamoviego4;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Classe che definisce nel dettaglio i campi relativi ad un generico film.
 * 
 * @author Gang of Four
 * */
@XmlRootElement
public class ParcelableDetailedMovie implements Parcelable {
	private String id;
	private String title;
	private String director;
	private String date;
	private List<String> actors;
	private List<ParcelableMovieType> movieTypes;
	private String thumbnailURL; // 32x32
	private String playbillURL;
	private String trailerURL;

	public ParcelableDetailedMovie() {
		title = "";
		id = "";
		date = "";
		thumbnailURL = "";
		director = "";
		actors = new ArrayList<String>();
		movieTypes = new ArrayList<ParcelableMovieType>();
		playbillURL = "";
		trailerURL = "";
	}

	public ParcelableDetailedMovie(String id, String title, String director,
			String date, List<String> actors,
			List<ParcelableMovieType> movieTypes, String thumbnailURL,
			String playbillURL, String trailerURL) {
		super();
		this.id = id;
		this.title = title;
		this.director = director;
		this.date = date;
		this.actors = actors;
		this.movieTypes = movieTypes;
		this.thumbnailURL = thumbnailURL;
		this.playbillURL = playbillURL;
		this.trailerURL = trailerURL;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDirector() {
		return director;
	}

	public void setDirector(String director) {
		this.director = director;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public List<String> getActors() {
		return actors;
	}

	public void setActors(List<String> actors) {
		this.actors = actors;
	}

	public List<ParcelableMovieType> getMovieTypes() {
		return movieTypes;
	}

	public void setMovieTypes(List<ParcelableMovieType> movieTypes) {
		this.movieTypes = movieTypes;
	}

	public String getThumbnailURL() {
		return thumbnailURL;
	}

	public void setThumbnailURL(String thumbnailURL) {
		this.thumbnailURL = thumbnailURL;
	}

	public String getPlaybillURL() {
		return playbillURL;
	}

	public void setPlaybillURL(String playbillURL) {
		this.playbillURL = playbillURL;
	}

	public String getTrailerURL() {
		return trailerURL;
	}

	public void setTrailerURL(String trailerURL) {
		this.trailerURL = trailerURL;
	}

	/**
	 * Metodo che descrive il genere di oggetti contenuti in questa
	 * rappresentazione di Parcelable.
	 * */
	@Override
	public int describeContents() {
		return 0;
	}

	/**
	 * Traduce quest'oggetto in un oggetto Parcel.
	 * */
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(id);
		dest.writeString(title);
		dest.writeString(director);
		dest.writeString(date);
		dest.writeStringList(actors);
		dest.writeList(movieTypes);
		dest.writeString(thumbnailURL);
		dest.writeString(playbillURL);
		dest.writeString(trailerURL);
	}

	/**
	 * Genera instanze della classe definita come Parcelable a partire da un
	 * oggetto Parcel.
	 * */
	public static final Parcelable.Creator<ParcelableDetailedMovie> CREATOR = new Parcelable.Creator<ParcelableDetailedMovie>() {
		public ParcelableDetailedMovie createFromParcel(Parcel in) {
			return new ParcelableDetailedMovie(in);
		}

		public ParcelableDetailedMovie[] newArray(int size) {
			return new ParcelableDetailedMovie[size];
		}
	};

	/**
	 * Costruttore che a partire da un Parcel ricostruisce un
	 * ParcelableDetailedMovie.
	 * */
	private ParcelableDetailedMovie(Parcel in) {
		this();

		this.id = in.readString();
		this.title = in.readString();
		this.director = in.readString();
		this.date = in.readString();
		in.readStringList(actors);
		in.readList(movieTypes, null);
		this.thumbnailURL = in.readString(); // 32x32
		this.playbillURL = in.readString();
		this.trailerURL = in.readString();
	}

}
